#include <fstream>
#include <iostream>
#include <cmath>

#define LOCAL_DEBUG 1

#if LOCAL_DEBUG
char input_file[] = "data.in";
#define INPUT in
#else
#define INPUT cin
#endif // LOCAL_DEBUG

using namespace std;

///////////////////////////////////////////////////////////
// Sample Input Data:
// 5
// 4
// 16
// 27
// 0
///////////////////////////////////////////////////////////

// ??? How about the input = 1 ?

unsigned int power(unsigned int X, unsigned int K)
{
    unsigned int ret = X;
    // K always > 1
    while(--K > 0) ret *= X; 
    return ret;   
}

float log2(float num)
{
    return log(num)/log(2.0);
}

int main(void)
{
    unsigned int num;
    unsigned int max_K;
    unsigned int max_X;
    
#if LOCAL_DEBUG
    ifstream in(input_file);
#endif // LOCAL_DEBUG

    while(INPUT.good())
    {
        INPUT>>num;
        
        if (num == 0)
            break;
        
        max_K = ceil(log2((float)num));
        max_X = ceil(sqrt((float)num));

        unsigned int K;
        unsigned int X;
        bool         find = false;
        
        K = 2;        
        while(K <= max_K)
        {
            X = max_X;
            while(0 < X)
            {
                unsigned int value = power(X, K);
                
                if (value == num)
                {
                    find = true;
                    break;                    
                }
                else if (value < num)
                {
                    break;
                }

                X--; 
            }
            
            if (find)
            {
                break;
            }

            K++;
        }
        
        if (find)
        {
            cout<<X<<" "<<K<<endl;
        }
        else {
            cout<<0<<" "<<0<<endl;
        }
    }

    return 0;
}
